#include <iostream>
#include <stdlib.h>
#include "Casher.h"

using namespace std;

template<class T>
void showLinkedList(LinkedList<T*>& list)
{
	LinkedListNode<T*>* n = list.getFirstNode();
	while(n != NULL)
	{
		cout << "person "
		<< /**n->getItem() */((Customer)(*n->getItem())).getCodigo()
		<< ", ";
		n = n->getNext();
	}
	cout << "QueueSize = " << list.size() << endl;
}

	
void Casher::addCustomer(Customer* customer)
{
	srand(time(NULL));
	int randNumber;
	
	randNumber = 1 + (int)(rand()%4); // 1 + (int) (4.0*rand()/(RAND_MAX+1.0));
	
	customer->setTimeAtentionDelay(randNumber);
	queue.push(customer);
	
}

void Casher::printState()
{
	if(queue.size() == 0)
		cout << "nobody in queue.." << endl;
	else
		showLinkedList(queue);
}

void Casher::atentionClient()
{
// 	if(attenting == NULL)
// 	{
// 		if(queue.size() > 0)
// 		{
// 			attenting = queue.pop();
// 			cout << attenting->getCodigo() << endl;
// 		}
// 	}
// 	else
// 	{
// 		int at = attenting->getTimeAtentionDelay();
// 		at--;
// 		if (at == 0)
// 		{
// 			attenting = NULL;
// 		}
// 
// 		attenting->setTimeAtentionDelay(at);
// 	}
}
